import { LogAddManager } from "../../../log_server/LogAddManager";
import { LogClearManager } from "../../../log_server/LogClearManager";
import { Config } from "../../config/Config";
import { ServerConfig } from "../../config/ServerConfig";
import { TimerManager } from "../../server/TimerManager";
import DateUtil from "./DateUtil";
import { EventManager } from "./EventManager";
import { Logger } from "./Logger";

export class TimerUtil {

    public static init() {
        setInterval(() => {
            try {
                let now: number = DateUtil.now();
                if (ServerConfig.nowServerConfig) {
                    TimerManager.instance.checkTimer(now)
                    if (Config.serverType == Config.ServerType_List.log_server) {
                        LogClearManager.instance.checkClear(now)
                        LogAddManager.instance.checkDayLog(now)
                    }
                 
                }
                EventManager.instance.dispatch(Config.Event_Config.Timer, now)
            } catch (error) {
                Logger.error("TimerUtil.error=-=", error)

            }
        }, 50)
    }
}